/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package control;

import java.io.Serializable;
import java.util.Locale;
import javax.faces.context.FacesContext;

/**
 *
 * @author AnBoCa
 */
public class Language implements Serializable{

    private String[] languages;
    private String selected;
    private Locale locale;
    
    /**
     * Creates a new instance of Language
     */
    public Language() {
        languages=new String[2];
        locale=FacesContext.getCurrentInstance().getViewRoot().getLocale();
        selected=locale.getLanguage();
        changeLang();
    }

    public final void changeLang() {
        languages[0]=selected;
        if (selected.equals("en")){
            languages[1]="es";
        }else{
            languages[1]="en";
        }
        locale=new Locale(selected);
    }
    
    public String[] getLanguages() {
        return languages;
    }

    public void setLanguages(String[] languages) {
        this.languages = languages;
    }

    public String getSelected() {
        return selected;
    }

    public void setSelected(String selected) {
        this.selected = selected;
    }

    public Locale getLocale() {
        return locale;
    }

    public void setLocale(Locale locale) {
        this.locale = locale;
    }
    
}
